<template>
  <div>
    <el-divider content-position="left" ><span style="color: red">池塘边素材</span></el-divider>
    <el-row :gutter="40" class="panel-group">

      <el-col :xs="12" :sm="12" :lg="6" class="card-panel-col">
        <div class="card-panel" @click="handleSetLineChartData('money')">
          <div class="card-panel-icon-wrapper icon-money">
            <svg-icon icon-class="money" class-name="card-panel-icon" />
          </div>
          <div class="card-panel-description">
            <div class="card-panel-text">
              今日会员收益
            </div>
            <count-to :start-val="0" :end-val="todayMemberFee" :duration="1200" class="card-panel-num" :decimals=1 />
          </div>
        </div>
      </el-col>

      <el-col :xs="12" :sm="12" :lg="6" class="card-panel-col">
        <div class="card-panel" @click="handleSetLineChartData('article')">
          <div class="card-panel-icon-wrapper icon-money">
            <svg-icon icon-class="money" class-name="card-panel-icon" />
          </div>
          <div class="card-panel-description">
            <div class="card-panel-text">
              今日文档收益
            </div>
            <count-to :start-val="0" :end-val="todayArticleFee" :duration="1200" :decimals=1 class="card-panel-num" />
          </div>
        </div>
      </el-col>

      <el-col :xs="12" :sm="12" :lg="6" class="card-panel-col">
        <div class="card-panel" @click="handleSetLineChartData('shoppings')">
          <div class="card-panel-icon-wrapper icon-shopping">
            <svg-icon icon-class="shopping" class-name="card-panel-icon" />
          </div>
          <div class="card-panel-description">
            <div class="card-panel-text">
              今日会员和文档收益
            </div>
            <count-to :start-val="0" :end-val="todayFee" :duration="1200" :decimals=1 class="card-panel-num" />
          </div>
        </div>
      </el-col>

      <el-col :xs="12" :sm="12" :lg="6" class="card-panel-col">
        <div class="card-panel" @click="handleSetLineChartData('shoppings')">
          <div class="card-panel-icon-wrapper icon-shopping">
            <svg-icon icon-class="shopping" class-name="card-panel-icon" />
          </div>
          <div class="card-panel-description">
            <div class="card-panel-text">
              池塘边素材总收益
            </div>
            <count-to :start-val="0" :end-val="countFee" :duration="1200" :decimals=1 class="card-panel-num" />
          </div>
        </div>
      </el-col>
    </el-row>
    <el-divider content-position="left"><span style="color: #80be24">池塘边文库</span></el-divider>
    <el-row :gutter="40" class="panel-group">

      <el-col :xs="12" :sm="12" :lg="6" class="card-panel-col">
        <div class="card-panel" @click="handleSetLineChartData('exCode')">
          <div class="card-panel-icon-wrapper icon-money">
            <svg-icon icon-class="money" class-name="card-panel-icon" />
          </div>
          <div class="card-panel-description">
            <div class="card-panel-text">
              今日兑换码收益
            </div>
            <count-to :start-val="0" :end-val="exCodeTodayMemberFee" :duration="1200" :decimals=1 class="card-panel-num" />
          </div>
        </div>
      </el-col>

      <el-col :xs="12" :sm="12" :lg="6" class="card-panel-col">
        <div class="card-panel" @click="handleSetLineChartData('shoppings')">
          <div class="card-panel-icon-wrapper icon-shopping">
            <svg-icon icon-class="shopping" class-name="card-panel-icon" />
          </div>
          <div class="card-panel-description">
            <div class="card-panel-text">
              池塘边文库总收益
            </div>
            <count-to :start-val="0" :end-val="exCodeMemberFee" :duration="1200"  :decimals=1 class="card-panel-num" />
          </div>
        </div>
      </el-col>

    </el-row>
    <el-divider content-position="left">用户信息</el-divider>
    <el-row :gutter="40" class="panel-group">
      <el-col :xs="12" :sm="12" :lg="6" class="card-panel-col">
        <div class="card-panel" @click="handleSetLineChartData('newVisitis')">
          <div class="card-panel-icon-wrapper icon-people">
            <svg-icon icon-class="peoples" class-name="card-panel-icon" />
          </div>
          <div class="card-panel-description">
            <div class="card-panel-text">
              今日新增用户
            </div>
            <count-to :start-val="0" :end-val="todayMewUser" :duration="2600" class="card-panel-num" />
          </div>
        </div>
      </el-col>
      <el-col :xs="12" :sm="12" :lg="6" class="card-panel-col">
        <div class="card-panel" @click="handleSetLineChartData('messages')">
          <div class="card-panel-icon-wrapper icon-message">
            <svg-icon icon-class="message" class-name="card-panel-icon" />
          </div>
          <div class="card-panel-description">
            <div class="card-panel-text">
              今日新增会员
            </div>
            <count-to :start-val="0" :end-val="todayMewMember" :duration="3000" class="card-panel-num" />
          </div>
        </div>
      </el-col>
      <el-col :xs="12" :sm="12" :lg="6" class="card-panel-col">
        <div class="card-panel" @click="handleSetLineChartData('shoppings')">
          <div class="card-panel-icon-wrapper icon-shopping">
            <svg-icon icon-class="shopping" class-name="card-panel-icon" />
          </div>
          <div class="card-panel-description">
            <div class="card-panel-text">
              总会员数
            </div>
            <count-to :start-val="0" :end-val="countMember" :duration="3600" class="card-panel-num" />
          </div>
        </div>
      </el-col>
      <el-col :xs="12" :sm="12" :lg="6" class="card-panel-col">
        <div class="card-panel" @click="handleSetLineChartData('shoppings')">
          <div class="card-panel-icon-wrapper icon-shopping">
            <svg-icon icon-class="shopping" class-name="card-panel-icon" />
          </div>
          <div class="card-panel-description">
            <div class="card-panel-text">
              总用户
            </div>
            <count-to :start-val="0" :end-val="countUser" :duration="3600" class="card-panel-num" />
          </div>
        </div>
      </el-col>
    </el-row>
  </div>

</template>

<script>
import CountTo from 'vue-count-to'
import {myGet} from "@/utils/myRequest";
const url = "/guard/article/summary"
export default {
  components: {
    CountTo
  },
  props:{
    memberData:{
      type:Object,
      default:{}
    }
  },

  data(){
    return {
      todayMewUser:0,
      todayMewMember:0,
      todayMemberFee:0,
      todayArticleFee:0,
      todayFee:0,
      countFee:0,
      countMember:0,
      countUser:0,
      exCodeTodayMemberFee:0,
      exCodeMemberFee:0,
    }
  },



  mounted() {

    this.todayMewUser = this.memberData.todayMewUser
    this.todayMewMember = this.memberData.todayMewMember
    this.todayMemberFee = this.memberData.todayMemberFee
    this.todayArticleFee = this.memberData.todayArticleFee
    this.todayFee = this.memberData.todayFee
    this.countFee = this.memberData.countFee
    this.countMember = this.memberData.countMember
    this.countUser = this.memberData.countUser
    this.exCodeTodayMemberFee = this.memberData.exCodeTodayMemberFee
    this.exCodeMemberFee = this.memberData.exCodeMemberFee

    /*myGet(url).then(res=>{
      if(res.status){
        this.todayMewUser = res.data.records.todayMewUser
        this.todayMewMember = res.data.records.todayMewMember
        this.todayFee = res.data.records.todayFee
        this.countFee = res.data.records.countFee
        this.countMember = res.data.records.countMember
        this.countUser = res.data.records.countUser
      }
    })*/
  },


  methods: {
    handleSetLineChartData(type) {
      this.$emit('handleSetLineChartData', type)
    }
  }
}
</script>

<style lang="scss" scoped>
.panel-group {
  margin-top: 18px;

  .card-panel-col {
    margin-bottom: 32px;
  }

  .card-panel {
    height: 108px;
    cursor: pointer;
    font-size: 12px;
    position: relative;
    overflow: hidden;
    color: #666;
    background: #fff;
    box-shadow: 4px 4px 40px rgba(0, 0, 0, .05);
    border-color: rgba(0, 0, 0, .05);

    &:hover {
      .card-panel-icon-wrapper {
        color: #fff;
      }

      .icon-people {
        background: #40c9c6;
      }

      .icon-message {
        background: #36a3f7;
      }

      .icon-money {
        background: #f4516c;
      }

      .icon-shopping {
        background: #34bfa3
      }
    }

    .icon-people {
      color: #40c9c6;
    }

    .icon-message {
      color: #36a3f7;
    }

    .icon-money {
      color: #f4516c;
    }

    .icon-shopping {
      color: #34bfa3
    }

    .card-panel-icon-wrapper {
      float: left;
      margin: 14px 0 0 14px;
      padding: 16px;
      transition: all 0.38s ease-out;
      border-radius: 6px;
    }

    .card-panel-icon {
      float: left;
      font-size: 48px;
    }

    .card-panel-description {
      float: right;
      font-weight: bold;
      margin: 26px;
      margin-left: 0px;

      .card-panel-text {
        line-height: 18px;
        color: rgba(0, 0, 0, 0.45);
        font-size: 16px;
        margin-bottom: 12px;
      }

      .card-panel-num {
        font-size: 20px;
      }
    }
  }
}

@media (max-width:550px) {
  .card-panel-description {
    display: none;
  }

  .card-panel-icon-wrapper {
    float: none !important;
    width: 100%;
    height: 100%;
    margin: 0 !important;

    .svg-icon {
      display: block;
      margin: 14px auto !important;
      float: none !important;
    }
  }
}
</style>
